<template>
<div>
    <div class="register_con">
		<div class="l_con fl">
			<a class="reg_logo"><img src="../assets/images/logo02.png"></a>
			<div class="reg_slogan">足不出户  ·  新鲜每一天</div>
			<div class="reg_banner"></div>
		</div>

		<div class="r_con fr">
			<div class="reg_title clearfix">
				<h1>用户注册</h1>
				<a href="#">登录</a>
			</div>
			<div class="reg_form clearfix">
				<form>
				<ul>
					<li>
						<label>用户名:</label>
						<input type="text" name="user_name" id="user_name" v-model="username">
						<span class="error_tip">提示信息</span>
					</li>					
					<li>
						<label>密码:</label>
						<input type="password" name="pwd" id="pwd" v-model="password">
						<span class="error_tip">提示信息</span>
					</li>
					<li>
						<label>确认密码:</label>
						<input type="password" name="cpwd" id="cpwd" v-model="password1">
						<span class="error_tip">提示信息</span>
					</li>
					<li>
						<label>邮箱:</label>
						<input type="text" name="email" id="email" v-model="email">
						<span class="error_tip">提示信息</span>
					</li>
					<li class="agreement">
						<input type="checkbox" name="allow" id="allow" v-model="allow">
						<label>同意”天天生鲜用户使用协议“</label>
						<span class="error_tip2">提示信息</span>
					</li>
					<li class="reg_sub">
						<input type="submit" value="注 册" name="" @click="register">
					</li>
				</ul>				
				</form>
			</div>

		</div>

	</div>

	<div class="footer no-mp">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
		<p>电话：010-****888    京ICP备*******8号</p>
	</div>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            username:'',
            password:'',
            password1:'',
            email:'',
            allow:false
        }
    },
    methods: {
        register(){
            const info={'username':this.username,'password':this.password,'email':this.email}
            axios.post('http://127.0.0.1:8000/user/',info)
            .then(resp=>{
                console.log(resp.data)
                alert(resp.data.msg)

                if(resp.data.code==400){
                    //处理错误
                    for(let key in resp.data.errors){
                        console.log(key)
                        console.log(resp.data.errors[key][0])
                    }
                }
            }).catch(error=>{
                console.log(error)
            })
        }
    },
    created() {

    }
}
</script>

<style scoped>

</style>
